﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Memo.Electricity.Engine;
using System.Net.Http.Headers;

namespace Memo.Electricity.Engine
{
	public class CSceneFadeBehaviour : StateMachineBehaviour
	{
		public int mFxNum;
		private CSceneFadeEffect.WaitForSceneFade mWait;
		

		public CSceneFadeEffect.WaitForSceneFade Play(Animator animator, bool isForward = true)
		{
			mWait = new CSceneFadeEffect.WaitForSceneFade();
			animator.SetBool("Mirror", !isForward);
			animator.SetInteger("FxId", Random.Range(1, mFxNum + 1));
			CTickMgr.Inst.RegisterOnce(() => animator.SetInteger("FxId", 0), 0.2f);
			return mWait;
		}

		public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
		{
			if(!stateInfo.IsName("Ready"))
			{
				mWait.isDown = true;
			}
				
		}
	}
}


